﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using St.MODLD;
using System.Data.Common;

namespace St.DAL
{
    public class GoodsDBHelper
    {
        static    DBHelper db = null;
        public GoodsDBHelper()
        {
            db = new SqlServerDBHelper();
        }
        public List<GoodsInfo> jiesuan(string Good) 
        {
            List<GoodsInfo> list = new List<GoodsInfo>();
            string sql = string.Format("select * from GoodsInfo where GoodsCode like '%"+ Good + "%'");

            DbDataReader dr = db.GetReader(sql);

            
            while (dr.Read())
            {
                GoodsInfo Goods = new GoodsInfo();
                Goods.GoodsCode = dr["GoodsCode"].ToString();
                Goods.GoodsName = dr["GoodsName"].ToString();
                Goods.OriginPrice = Convert.ToDouble(dr["OriginPrice"]);
                Goods.SalePrice = Convert.ToDouble(dr["SalePrice"]);
                Goods.Stock = Convert.ToInt32(dr["Stock"]);
                Goods.Unit = dr["Unit"].ToString();
                Goods.Supplier = Convert.ToInt32(dr["Supplier"]);
                Goods.Company = Convert.ToInt32(dr["Company"]);
                Goods.GoodsState = Convert.ToInt32(dr["GoodsState"]);
                list.Add(Goods);
            }
            dr.Close();
            db.Close();
            return list;
        }
    }
}
